Hi Scott,
I think you could create some logic based on the current and previous hall states to determine when the state changes whether it was a positive or negative motion. I cant think of an extremely elegant way to do it. On approach would be to make a table to map the index to a sequence number. That way each Hall state could be mapped to a consecutive sequence number 0 to 5. Subtracting the previous sample of the hall state sequence would yield the change. For example if the previous was 3 and the new is 4 then 4 - 3 = 1 so we changed +1. Or 4-4=0 would be no change. Or 3 - 4 = -1 would be a chage of -1. How ever you would need to handle the two wrap around cases. Previous of 5 and new of 0 would have a result of -5 which should be treated as +1. Previous of 0 and new of 5 would have a result of +5 and should be treated as a -1. So something like:
int SequenceTable{8] = {1,3,4,5,99,2,0,99}; // put whatever the real order is and 99 for the two invalid states
.
.
.
New = SequenceTable[Index];
Diff = New-Prev;
if (Diff==1 || Diff == -5)
ch5->Position++; // count up
else if (Diff=-1 || Diff == 5)
ch5->Position--; // count down
else if (Diff != 0)
printf('Something wrong\n");;
Prev=Diff;
HTH
Regards
TK